<template>
  <div>
    <Myadv />
    <div :style="{ background: obj.backgroundColor }" class="html">
      <p class="header-title">猫眼电影&gt;{{ obj.nm }}</p>
      <!-- 点电影信息 -->
      <div class="movies-detail-header">
        <img :src="obj.img | formatUrl" alt="" />
        <div class="detail-content">
          <h1 class="title">{{ obj.nm }}</h1>
          <p>{{ obj.filmAlias }}</p>
          <p>
            {{ obj.cat }}<i class="ver">{{ obj.ver + "MAX" }}</i>
          </p>
          <p>{{ obj.star }}</p>
          <p>{{ obj.pubDesc }}</p>
          <div class="btn">
            <span class="lookbtn">
              <i class="iconfont icon-aixin"></i>
              想看
            </span>
            <span class="lookbtn">
              <i class="iconfont icon-xingxing"></i>
              看过
            </span>
          </div>
        </div>
      </div>
      <!-- 电影评分 -->
      <div class="movies-sc">
        <p class="heder-sc">
          <span><i class="iconfont icon-fenlei-maozi"></i>猫眼购票评分</span>
          <b>
            {{ obj.wish }}人想看，{{ obj.watched }}人看过
            <i class="iconfont icon-youjiantou_huaban"></i>
          </b>
        </p>
        <div class="sc-box">
          <div class="sc-box-left">
            <span class="sc">{{ obj.sc }}</span>
            <span>{{ obj.snum }}人评</span>
          </div>
          <div class="sc-box-right">
            <p
              v-for="(item, index) in obj.distributions"
              :key="item.proportion"
            >
              <img
                src="https://s0.meituan.net/bs/myfe/canary/file/asgard/images/movie/star-not-graded.png"
                alt=""
                v-for="j in 3 - index"
                :key="j"
              />
              <span class="lenght">
                <b :style="{ width: item.proportion + '%' }"></b>
              </span>
            </p>
          </div>
        </div>
      </div>
      <!-- 简介 -->
      <div class="brief-introduction">
        <div class="div-title">
          <span>简介</span>
          <span>
            更多
            <i class="iconfont icon-youjiantou_huaban"></i>
          </span>
        </div>
        <div class="line-clamp">
          {{ obj.dra }}
        </div>
      </div>
      <div class="brief-introduction">
        <div class="div-title">
          <span>演职人员</span>
          <span>全部<i class="iconfont icon-youjiantou_huaban"></i></span>
        </div>
        <!-- 演员相册 -->
        <div class="line-photos">
          <img
            :src="item | formatUrl"
            v-for="item in obj.photos"
            :key="item"
            alt=""
          />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Myadv from "../components/public/Myadv";
import { postMoviesDetailApi } from "../utils/api";
export default {
  data() {
    return {
      id: "",
      obj: "",
    };
  },
  async beforeRouteEnter(to, from, next) {
    const res = await postMoviesDetailApi({ id: to.params.id });
    next((vm) => {
      vm.obj = res.result;
      document.title = `《${vm.obj.nm}》_购票_剧情介绍`;
    });
  },
  components: {
    Myadv,
  },
  filters: {
    formatUrl(val) {
      return val?.split("/w.h").join("/64.90");
    },
  },
};
</script>

<style lang="less" scoped>
@import "../assets/css/var.less";
.html {
  height: 100vh;
  padding: 21px 16px;
  color: #ccc;
  .header-title {
    font-size: @s-font;
    line-height: 21px;
    margin-bottom: 15px;
  }
  .movies-detail-header {
    height: 138px;
    width: 100%;
    position: relative;
    overflow: hidden;
    .center();
    img {
      width: 100px;
      height: 138px;
    }
    .detail-content {
      flex: 1;
      height: 138px;
      padding-left: 10px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      p {
        width: 220px;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        font-size: @s-font;
        line-height: 18px;
        .ver {
          display: inline-block;
          height: 16px;
          border-radius: 3px;
          background: rgba(255, 255, 255, 0.356);
          color: #fff;
          font-size: 6px;
          padding: 0 3px;
          margin-left: 3px;
          line-height: 16px;
          vertical-align: hidden;
        }
      }
      .btn {
        font-size: @s-font;
        display: flex;
        justify-content: space-between;
      }
      .lookbtn {
        display: inline-block;
        width: 110px;
        height: 30px;
        border-radius: 5px;
        background: rgba(255, 255, 255, 0.35);
        text-align: center;
        line-height: 30px;
        color: #fff;
      }
    }
    .title {
      font-size: 20px;
      height: 30px;
      line-height: 30px;
      color: #fff;
    }
  }
  .movies-sc {
    background: rgba(0, 0, 0, 0.3);
    width: 100%;
    height: 90px;
    border-radius: 8px;
    padding: 8px 12px;
    margin-top: 15px;
    font-size: @xs-font;
    .heder-sc {
      display: flex;
      justify-content: space-between;
      i {
        font-size: 10px;
      }
      .icon-fenlei-maozi {
        color: @m-color;
        margin-right: 5px;
      }
    }
    .sc {
      font-size: 22px;
      color: goldenrod;
      font-weight: 900;
    }
    .sc-box {
      .center();
      .sc-box-left {
        display: flex;
        flex-direction: column;
        align-items: center;
      }
      .sc-box-right {
        width: 94px;
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        margin: 10px;
        img {
          width: 5px;
          height: 5px;
          margin: 0 1px;
        }
        .lenght {
          width: 56px;
          display: inline-block;
          height: 5px;
          background: rgba(0, 0, 0, 0.3);
          position: relative;
          margin-left: 5px;
          b {
            position: absolute;
            height: 5px;
            left: 0;
            top: 0;
            display: inline-block;
            background: goldenrod;
          }
        }
      }
    }
  }
  .div-title {
    display: flex;
    justify-content: space-between;
  }
  .brief-introduction {
    font-size: 15px;
    padding-top: 16px;
    .line-clamp {
      height: 78px;
      width: 100%;
      margin: 7px 0;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 3;
      text-overflow: ellipsis;
      word-wrap: break-word;
      word-break: break-all;
      overflow: hidden;
      line-height: 25px;
    }
    .line-photos {
      padding-top: 16px;
      width: 100%;
      height: 181px;
      margin: 18px 0 15px 0;
      overflow: auto;
      display: inline-flex;
      img {
        width: 80px;
        height: 112px;
        margin-right: 5px;
      }
    }
  }
}
</style>
